package com.restaurant.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.restaurant.domain.Foodtype;

public class FoodTypeFormValidator implements Validator{
	
	@Override
	public boolean supports(Class<?> arg0) {
		return Foodtype.class.isAssignableFrom(arg0);
	}

	@Override
	public void validate(Object arg0, Errors errors) {
		//ValidationUtils.rejectIfEmptyOrWhitespace(arg1, "foodname", "foodtype.name");
		Foodtype foodtype = (Foodtype) arg0;
		
		if(foodtype.getFoodname().trim().length() <= 0){
			errors.rejectValue("foodname", "foodtype.name");
		}
	}

}
